- Inheritance:

* Parent class - is a --> Child class
* protected reserved word
* super (use the constructor of the parent class) ---> super();
super can also be used to call a method defined inside the body of the parent class. This 
could be useful when you override the implementation of an inherited method.
* Method overriding
* Abstract class: class with 0 or more abstract methods
Class having at least 1 abstract method must be made abstract
Restriction: we cannot instantiate an abstract class

Abstract class <=> placeholder for the variables and methods (features) shared
among all descendants of the abstract class

Plane -	Vehicle ---> Car
	|
	|
	Boat

All vehicles have a speed ==> Create inside the vehicle class a speed variable
Not all vehicles have weels ===> Create nbOfWheels at the relevant leval (Car, plane)
fuelConsumption method ==> strategy: create it as an abstract method inside Vehicle and
then let the descendant dictate their own implementations of that method

- Can a class be derived from multiple parent classes (Multiple inheritance)?
Multiple inheritance is not supported by Java, in the sense that a child class can have
only one parent class.

Through interfaces, we can create in Java multiple "is a" relationships.  

- RollingDice.java and Die.java
public class Die extends Object

===> Die would inherit toString + equals
Object's version of toString prints the name of class followed by @ followed a hash value
Object's version of equals checks whether the two objects that are being compared are aliases

die1 ---> faceValue: 5
die2 ---> faceValue: 5

Objective: override the implementation of equals

Application#1:
RollingDice.java
Die.java

- Application#2: LeetCode 724
 0	1	2	3	4
[1	2	3	0	3]

Two solutions: solution#1 (O(n^2)); through a preprocessing step ===> O(n) solution#2

- Finding the second smallest value of an array
arr
[1	4	3	2]

Arrays.sort(arr);
return arr[1];

- Application#3: Misc.java
Objective: finding the second min in an array 

- Last topic: in Java, parameters are passed by value
Application#4: SwappingValues.java

main
int val1: 2 and val2: 3
swap(2, 3)

swap
int val1: 3 and val2: 2

Problem: swap acts on the copies not the originals

main:

val1 ---> 2 <--- val1 and val2 ---> 3 <--- val2


int[] arr = {1, 2, 3};
System.out.println(arr); // Address of the first value
---------------------------------------------------------------------------

Andrei Karpathy
"You can delegate thinking to an LLM but you cannot delegate understanding to an LLM"













 

















